package com.jml.essingle.controller;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.jml.essingle.entity.UserEntity;
import com.jml.essingle.dao.UserDao;

@RestController
public class EsController {

	@Autowired
	private UserDao userDao;

	//添加文档
	@RequestMapping("/addUser")
	public UserEntity addUser(String name) {
		UserEntity user = new UserEntity();
		user.setAge(1);
		user.setId("1");
		user.setName(name);
		user.setSex(1);
		return userDao.save(user);
	}
	//查询文档   查的是/jml/user/id
	@RequestMapping("/findUser")
	public Optional<UserEntity> findUser(String id) {
		return userDao.findById(id);
	}
}
